#ifndef _tlist_h_
#define _tlist_h_

#include <iostream>
#include "structs.h"

using namespace std;

namespace wcd {

template <class T>
class ListOne
{
    public:
        ListOne():head(0), tail(0){};
        ~ListOne();

        void push_back(T val);
        void display() const;
    private:
        Node<T> * head;
        Node<T> * tail;
};

//template <class T>
//void ListOne<T>::push_front(T val)
//{
//    Node<T> * newNode = new Node<T>;

//    newNode->data = val;
//    newNode->next = head;

//    head = newNode;

//    if(tail==0)
//        tail = head;
//}

template <class T>
void ListOne<T>::push_back(T val)
{
    Node<T> * newNode = new Node<T>(val);

    newNode->data = val;
    newNode->Next = 0;

    if(tail==0)
    {
        head = tail = newNode;
        return;
    }

    tail->Next = newNode;
    tail = newNode;
}

template <class T>
ListOne<T>::~ListOne()
{
    Node<T> * tmp;
    while(head)
    {
        tmp = head;
        head = head->Next;
        delete tmp;
    }
}

template <class T>
void ListOne<T>::display() const
{
    Node<T> * current = head;

    while(current)
    {
        cout<<current->data<<' ';
        current = current->Next;
    }
}

//template <class T>
//void ListOne<T>::reverse()
//{
//    if (head == 0)
//        return;

//    tail = head;

//    Node<T> * current = head->next;
//    Node<T> * right;

//    while(current)
//    {
//        right = current->next;

//        current->next = head;
//        head = current;
//        current = right;
//    }

//    tail->next = 0;
//}

} // namespace wcd
#endif

